<?php


namespace app\common\model\mysql;


use think\Model;

class BaseModel extends Model
{
    protected $autoWriteTimestamp = true;
    public function updateById($id, $data){
        $data['update_time'] = date("Y-m-d H:i:s",time());
        return $this->where(["id" => $id])->save($data);
    }

    public function getNormalInIds($ids){
        $res = $this->whereIn("id", $ids)
            ->where('status','=', config('status.mysql.table_normal'))
            ->select();
        return $res;
    }

    public function getByCondition($condition = [], $order = ['id' => 'desc']){
        if(!$condition || !is_array($condition)){
            return false;
        }
        $result = $this->where($condition)
            ->order($order)
            ->select();
        // echo $this->getLastSql();exit;
        return $result;
    }
}
